package demo.liu.two.controller;

import java.util.concurrent.*;

/**
 * @author by Liujt
 * @Classname TestFutureGet
 * @Description TODO
 * @Date 2021/7/8 13:58
 */
public class TestFutureGet {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        BlockingQueue workQueue = new LinkedBlockingDeque();
        ThreadPoolExecutor executorService = new ThreadPoolExecutor
                (3, 3, 10, TimeUnit.SECONDS, workQueue);
        Future<String> future = executorService.submit(() -> {
            Thread.sleep(10000);
            return "a";
        });
        Future<String> future2 = executorService.submit(() -> {
            Thread.sleep(10000);
            return "a";
        });
        Future<String> future3 = executorService.submit(() -> {
            Thread.sleep(30000);
            return "a";
        });
        Long a = System.currentTimeMillis();
        System.out.println(future.get());
        System.out.println(System.currentTimeMillis() - a);
        System.out.println(future2.get());
        System.out.println(System.currentTimeMillis() - a);
        System.out.println(future3.get());
        System.out.println(System.currentTimeMillis() - a);
    }
}
